<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>悬停选项卡切换</title>
    <style>
        body {
            font-family: Arial, sans-serif;
        }
        .tabs {
            display: flex;
            cursor: pointer;
            margin-bottom: 10px;
        }
        .tab {
            padding: 10px 20px;
            margin-right: 5px;
            background-color: #f9f9f9;
        }
        .tab.active {
            background-color: #ddd;
            font-weight: bold;
        }
        .content {
            display: none;
            padding: 10px;
        }
        .content.active {
            display: block;
        }
        .content .one{
            border: 2px solid #000;
            width: 300px;
            height: 30px;
        }
        .content .tow{
            border: 2px solid #f00;
            width: 300px;
            height: 30px;
        }
        .content .three{
            border: 2px solid #0f0;
            width: 300px;
            height: 30px;
        }
        .content button{
            width: 50px;
            height: 35px;
            color: #fff;
            border: none;
        }
        .content .one1{
            background-color: #000;
        }
        .content .tow2{
            background-color: #f00;
        }
        .content .three3{
            background-color: #0f0;
        }
    </style>
    <!-- 引入jQuery库 -->
    <script src="../jq/jQuery-3.7.1.js"></script>
</head>
<body>
    <div class="tabs">
        <div class="tab active" data-target="content1">宝贝</div>
        <div class="tab" data-target="content2">天猫</div>
        <div class="tab" data-target="content3">店铺</div>
    </div>
    <div class="contents">
        <div id="content1" class="content active">
            <p><input type="text" value="" class="one" placeholder="输入宝贝"><button class="one1">搜索</button></p>
        </div>
        <div id="content2" class="content">
            <p><input type="text" value="" class="tow" placeholder="输入宝贝"><button class="tow2">搜索</button></p>
        </div>
        <div id="content3" class="content">
            <p><input type="text" value="" class="three" placeholder="输入店铺"><button class="three3">搜索</button></p>
        </div>
    </div>

    <script>
        $(document).ready(function() {
            // 鼠标悬停切换选项卡
            $('.tab').hover(function() {
                // 移除所有选项卡和内容的active类
                $('.tab').removeClass('active');
                $('.content').removeClass('active');
                
                // 为当前悬停的选项卡添加active类
                $(this).addClass('active');
                
                // 显示对应的内容
                var target = $(this).data('target');
                $('#' + target).addClass('active');
            });
            
            // 保持第一个选项卡默认激活状态
            $('.tab:first').trigger('mouseenter');
        });
    </script>
</body>
</html>